<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        const arr = [1, 2, 3, 4, 5, 6];
                           
        //从下标2开始，改变数组的数据，数据来自于下标0位置开始
        // arr.copyWithin(2); // [1, 2, 1, 2, 3, 4]

        // arr.copyWithin(2, 1); // [1, 2, 2, 3, 4, 5]

        // arr.copyWithin(2, 1, 3); // [1, 2, 2, 3, 5, 6]  第3个参数不包含末尾项3
        console.log(arr)
    </script>
</body>

</html>
